import request from '@/utils/request'
import type { 
  ApiResponse,
  Like
} from '@/types'

// 点赞相关API
export const likeApi = {
  // 点赞/取消点赞
  toggleLike: (data: { targetType: string; targetId: number }): Promise<ApiResponse<string>> => {
    return request.post('/likes', data)
  },

  // 获取点赞状态
  getLikeStatus: (params: { targetType: string; targetId: number }): Promise<ApiResponse<boolean>> => {
    return request.get('/likes/status', { params })
  },

  // 获取文章点赞列表
  getPostLikes: (postId: number): Promise<ApiResponse<Like[]>> => {
    return request.get(`/likes/posts/${postId}/likes`)
  },

  // 获取评论点赞列表
  getCommentLikes: (commentId: number): Promise<ApiResponse<Like[]>> => {
    return request.get(`/likes/comments/${commentId}/likes`)
  },

  // 获取目标点赞数
  getLikeCount: (params: { targetType: string; targetId: number }): Promise<ApiResponse<number>> => {
    return request.get('/likes/count', { params })
  }
}